package com.book.oauth.server.user.hystrix;

import com.book.common.result.PageInfo;
import com.book.common.result.RestResponse;
import com.book.oauth.server.user.dto.UserDto;
import com.book.oauth.server.user.hystrix.impl.UserHystrixImpl;
import com.book.oauth.server.user.vo.UserVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * Description：用户 Hystrix
 *
 * @Author： leo.xiong
 * @CreateDate： 2020-04-26
 * @Email： leo.xiong@suyun360.com
 * @Version:
 */
@FeignClient(value = "oauth-server", fallbackFactory = UserHystrixImpl.class)
public interface IUserHystrix {
    /**
     * 根据ID获取用户信息
     *
     * @param id
     * @return
     */
    @GetMapping(value = "/server/user/{id}", consumes = "application/json")
    RestResponse<UserVo> get(@PathVariable(value = "id") String id);

    /**
     * 查询用户信息
     *
     * @param userDto
     * @return
     */
    @PostMapping(value = "/server/user/list", consumes = "application/json")
    RestResponse<List<UserVo>> list(@RequestBody UserDto userDto);

    /**
     * 查询用户信息
     *
     * @param userDto
     * @return
     */
    @PostMapping(value = "/server/user/page/list", consumes = "application/json")
    RestResponse<PageInfo<UserVo>> pageList(@RequestBody UserDto userDto);

    /**
     * 新增用户信息
     *
     * @param userDto
     * @return
     */
    @PostMapping(value = "/server/user/save", consumes = "application/json")
    RestResponse<String> save(@RequestBody UserDto userDto);

    /**
     * 修改用户信息
     *
     * @param userDto
     * @return
     */
    @PutMapping(value = "/server/user/update", consumes = "application/json")
    RestResponse<String> update(@RequestBody UserDto userDto);

    /**
     * 删除用户信息
     *
     * @param id
     * @return
     */
    @DeleteMapping(value = "/server/user/delete/{id}", consumes = "application/json")
    RestResponse<String> delete(@RequestParam(value = "id") String id);

    /**
     * 导出用户模板信息
     *
     * @return
     */
    @PostMapping(value = "/server/user/export/template", consumes = "application/json")
    RestResponse<String> exportTemplate();

    /**
     * 导出用户信息
     *
     * @param userDto
     * @return
     */
    @PostMapping(value = "/server/user/export/excel", consumes = "application/json")
    RestResponse<String> exportExcel(@RequestBody UserDto userDto);

    /**
     * 导入用户信息
     *
     * @param filePath
     * @return
     */
    @PostMapping(value = "/server/user/import/excel", consumes = "application/json")
    RestResponse<String> importExcel(@RequestParam(value = "filePath") String filePath);

    /**
     * 修改最后登录时间并保存登录日志信息
     *
     * @param userId
     * @param userName
     * @param location
     * @param ip
     * @param browser
     * @param systemInfo
     * @return
     */
    @PostMapping(value = "/server/user/update/login/time")
    RestResponse<String> updateLoginTime(@RequestParam(value = "userId") String userId,
                                         @RequestParam(value = "userName") String userName,
                                         @RequestParam(value = "location") String location,
                                         @RequestParam(value = "ip") String ip,
                                         @RequestParam(value = "browser") String browser,
                                         @RequestParam(value = "systemInfo") String systemInfo);

    /**
     * 根据Id重置密码
     *
     * @param id
     * @return
     */
    @PostMapping(value = "/server/user/reset/password")
    RestResponse<String> resetPassword(@RequestParam(value = "id") Long id);

    /**
     * 修改密码
     *
     * @param id
     * @param oldPassword
     * @param password
     */
    @PostMapping(value = "/server/user/update/password")
    RestResponse<String> updatePassword(@RequestParam(value = "id") Long id, @RequestParam(value = "oldPassword") String oldPassword, @RequestParam(value = "password") String password);

    /**
     * 修改头像信息
     *
     * @param id
     * @param avatar
     */
    @PostMapping(value = "/server/user/update/avatar")
    RestResponse<String> updateAvatar(@RequestParam(value = "id") Long id, @RequestParam(value = "avatar") String avatar);

    /**
     * 修改主题信息
     *
     * @param id
     * @param theme
     */
    @PostMapping(value = "/server/user/update/theme")
    RestResponse<String> updateTheme(@RequestParam(value = "id") Long id, @RequestParam(value = "theme") String theme);

    /**
     * 修改tab信息
     *
     * @param id
     * @param isTab
     */
    @PostMapping(value = "/server/user/update/tab")
    RestResponse<String> updateTab(@RequestParam(value = "id") Long id, @RequestParam(value = "isTab") String isTab);
}
